﻿using HCI.Questionaire.Exceptions;

namespace HCI.Questionaire.Entities
{
    public class MultipleAnswerQuestion : Question
    {
        private bool m_IsRequired;

        public bool IsRequired
        {
            get { return m_IsRequired; }
            set { m_IsRequired = value; }
        }

        public override void ValidateAnswer()
        {
            int count = 0;
            this.AnswerCollection.ForEach(o => { if (o.IsAnswered) count++; });

            if (this.IsRequired &&  count <= 1)
                throw new RequiredAnswerException("Required at less on answer.");
        }
    }

    
}
